home *** CD-ROM | disk | FTP | other *** search
- /*
- File: TInitSLM.h
-
- Contains: Contains the declaration and implementation of the TInitSLM class.
- It also #includes all of the Shared Library Manager interface files
- we will need.
-
- Copyright: © 1993 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #ifndef __TINITSLM__
- #define __TINITSLM__
-
- #ifndef __GLOBALNEW__
- #include <GlobalNew.h> // this will make all of our "news" allocate out of memory pools
- #endif
-
- #ifndef __LIBRARYMANAGERCLASSES__
- #include <LibraryManagerClasses.h>
- #endif
-
- #ifndef __LIBRARYMANAGERUTILITIES__
- #include <LibraryManagerUtilities.h>
- #endif
-
- #ifndef __STDIO__
- #include <stdio.h>
- #endif
-
- #ifndef __STRING__
- #include <string.h>
- #endif
-
- #ifndef __IOSTREAM__
- #include <iostream.h>
- #endif
-
- ///————————————————————————————————————————————————————————————————————————————————————
- /// TInitSLM
- ///
- /// This class initializes Shared Library Manager when it is constructed and cleans
- /// up when it is destroyed.
- ///————————————————————————————————————————————————————————————————————————————————————
-
- class TInitSLM {
-
- public:
- TInitSLM(); // initialize the shared library manager
- virtual ~TInitSLM(); // cleanup and dispose our local TLibraryManager
- Boolean Failed() const { return (fSuccess == false); } // true if we failed
- protected:
- Boolean fSuccess; // indicate if InitLibraryManager call succeeded
- };
-
- ///————————————————————————————————————————————————————————————————————————————————————
- /// TInitSLM IMLEMENTATION
- ///————————————————————————————————————————————————————————————————————————————————————
-
- TInitSLM::TInitSLM()
- {
- fSuccess = false;
- if( InitLibraryManager() == noErr )
- if( GetLocalLibraryManager() )
- fSuccess = true;
- }
-
- TInitSLM::~TInitSLM()
- {
- if( fSuccess )
- CleanupLibraryManager();
- else
- cout << "Sorry, failed to initialize/load the Shared Library Manager" << endl;
- }
-
- #endif